FROM centos:centos7
LABEL qingdalf qingdalf@foxmail.com

ADD nginx-1.18.0.tar.gz  /

RUN yum -y install net-tools yum  gcc gcc-c++ make openssl-devel \
 pcre-devel perl-ExtUtils-Embed zlib-devel libxslt-devel GeoIP-devel gd-devel net-tools \
 net-tools wget curl cronie && groupadd nginx && useradd -g nginx nginx && rm -rf /var/cache/yum/*

RUN cd nginx-1.18.0 && ./configure --prefix=/srv/nginx --user=nginx --group=nginx \
 --with-file-aio --with-http_auth_request_module \
 --with-http_ssl_module --with-http_v2_module \
 --with-http_realip_module --with-http_addition_module \
 --with-http_xslt_module=dynamic --with-http_geoip_module=dynamic \
 --with-http_sub_module --with-http_dav_module --with-http_flv_module\
 --with-http_mp4_module --with-http_gunzip_module \
 --with-http_gzip_static_module --with-http_random_index_module \
 --with-http_secure_link_module --with-http_degradation_module \
 --with-http_slice_module --with-http_stub_status_module \
 --with-http_perl_module=dynamic --with-pcre --with-pcre-jit \
 --with-stream=dynamic --with-stream_ssl_module && \
 make -j 4  && make install && mkdir /srv/nginx/conf/vhost && \
cd / && rm -rf nginx* && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ENV PATH $PATH:/srv/nginx/sbin

COPY --chown=nginx:nginx ./nginx.conf /srv/nginx/conf/nginx.conf
COPY --chown=nginx:nginx --chmod=755 ./log.sh /srv/nginx/log.sh

RUN  mkdir -p /var/spool/cron/ && echo "* 2 * * * /usr/bin/bash /srv/nginx/log.sh" > /var/spool/cron/nginx

WORKDIR /srv/nginx

EXPOSE 80

CMD ["/srv/nginx/sbin/nginx","-g","daemon off;"]